<script setup>
import { ref } from 'vue'
import { paginateArray } from '@/utils/common'
const showPop = ref(false)
const flightList = ref([])
const emits = defineEmits(['closeFlight'])
const close = () => {
  showPop.value = false
  emits('closeFlight')
}
const currentPage = ref(1)
const pageSize = ref(10)
const setData = (data) => {
  showPop.value = true
  flightList.value = paginateArray(data, pageSize.value)
}
const handleCurrentPageChange = (val) => {
  currentPage.value = val
}
defineExpose({
  setData,
  close
})
</script>
<template>
  <transition
    appear
    name="custom-classes-transition"
    enter-active-class="animate__animated  animate__fadeIn"
    leave-active-class="animate__animated animate__faster  animate__fadeOut"
  >
    <div class="flightList" v-drag v-if="showPop">
      <p class="title">
        <span>起降点信息</span>
        <span @click="close"><img src="@img/pop/close_icon.png" alt="" /></span>
      </p>
      <div class="content">
        <div class="table">
          <ul>
            <li class="header">
              <p>航班类型</p>
              <p>航飞开始时间</p>
              <p>航飞结束时间</p>
              <p>飞行任务</p>
              <p>飞行时长</p>
              <p>航班起飞点</p>
              <p>航班降落点</p>
            </li>
          </ul>
          <ul v-if="flightList.length">
            <li v-for="(item, index) in flightList[currentPage - 1]" :key="index">
              <p>{{ item.usageName }}</p>
              <p>{{ item.flyStartTime }}</p>
              <p>{{ item.flyEndTime }}</p>
              <p>{{ item.taskNature }}</p>
              <p>{{ item.time }}</p>
              <p>{{ item.risePoint }}</p>
              <p>{{ item.landPoint }}</p>
            </li>
          </ul>
        </div>
        <div class="footer">
          <p>共{{ flightList.length }}条</p>
          <p>
            <el-pagination
              layout="prev, pager, next"
              :total="flightList.length"
              :page-size="pageSize"
              @current-change="handleCurrentPageChange"
            />
          </p>
        </div>
      </div>
    </div>
  </transition>
</template>
<style scoped lang="scss">
.flightList {
  position: fixed;
  z-index: 9;
  top: 50%;
  left: 50%;
  width: 840px;
  height: 560px;
  transform: translate3d(-50%, -50%, 0);
  background: url('@img/pop/list_bg.png');
  background-size: 100% 100%;

  .title {
    display: flex;
    padding: 10px 20px 10px 50px;
    align-items: center;
    font-size: 16px;
    justify-content: space-between;

    span:last-child {
      width: 18px;
      height: 18px;
      cursor: pointer;

      img {
        width: 100%;
        height: 100%;
      }
    }
  }

  .content {
    margin: 15px;

    .table {
      width: 100%;
      margin-top: 15px;
      height: 450px;
      overflow-y: auto;

      li {
        display: flex;
        align-items: center;
        height: 40px;
        border-bottom: 1px solid #0f496c;

        &.header {
          color: #00d5ff;
          background: radial-gradient(
              1443% 84% at 50% 0%,
              rgba(106, 220, 255, 0.77) 0%,
              rgba(0, 203, 255, 0.34) 47%,
              rgba(49, 149, 189, 0) 100%
            ),
            rgba(0, 213, 255, 0.16);
        }

        &:nth-child(odd) {
          background-color: rgba(15, 73, 108, 0.3);
        }

        p {
          flex: 2;
          display: flex;
          align-items: center;
          &:nth-child(2),
          &:nth-child(3) {
            flex: 3;
          }
        }
      }
    }

    .footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 10px;

      :deep() {
        .el-pager li,
        .el-pagination button {
          background: none !important;
          color: #fff !important;
        }

        .el-pager li.is-active {
          min-width: 22px !important;
          width: 22px !important;
          height: 22px !important;
          background: #1fc6ff !important;
          border-radius: 50% !important;
        }
      }
    }
  }
}
</style>
